<template>
	<div>
		<!-- 提到我的问题列表 -->
		<div style="margin-top: 5%;">
			<div style="width: 100%;">
				<van-button custom-style="width: 50%;" type="default" @click="getHaveAnswer()">已回答</van-button>
				<van-button custom-style="width: 50%;" type="default" @click="getNoAnswer()">未回答</van-button>
			</div>
			<div v-for="(item, index) in quetion_list" :key="index">
				<van-cell is-link @click="getQuestionDetail(item)">
					<view slot="title">
						<van-row gutter="20">
							<van-col span="3">
								<image v-if="img_type === '1'"
									src="https://czsc.oss-cn-beijing.aliyuncs.com/mini/wh.png"
									style="width: 30px;height: 30px;"></image>
								<image v-if="img_type === '0'"
									src="https://czsc.oss-cn-beijing.aliyuncs.com/mini/dg.png"
									style="width: 30px;height: 30px;"></image>
							</van-col>
							<van-col span="20">
								<view class="van-cell-text" style="font-size: 15px;font-family: '苹方';margin-top: 5px;">
									{{ item.questionTitle }}</view>
							</van-col>
						</van-row>
					</view>
				</van-cell>
			</div>
		</div>
	</div>
</template>

<script>
	export default{
		data(){
			return{
				quetion_list: [],
				img_type: '0',
			}
		},
		created() {
			this.getNoAnswer();
		},
		methods: {
			getHaveAnswer(){
				this.img_type = '0';
				uni.request({
					method: 'GET',
					url: 'https://www.gjegm.ltd/czsczq/expertQuestion/getHaveAnswerQuestion',
					data: {
						type: '1',
						answer_username: uni.getStorageSync('username')
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded',
						'token': uni.getStorageSync('token')
					},
					success: (res1) => {
						this.quetion_list = res1.data.obj;
					}
				});
			},
			getNoAnswer(){
				this.img_type = '1';
				uni.request({
					method: 'GET',
					url: 'https://www.gjegm.ltd/czsczq/expertQuestion/getNoAnswerQuestion',
					data: {
						type: '1',
						answer_username: uni.getStorageSync('username')
					},
					header: {
						'content-type': 'application/x-www-form-urlencoded',
						'token': uni.getStorageSync('token')
					},
					success: (res1) => {
						this.quetion_list = res1.data.obj;
					}
				});
			},
			getQuestionDetail(val){
				if(this.img_type === '0'){
					uni.navigateTo({
						url: '/pages/question_answer/question_haveanswer?id=' + val.id + '&question=' + val.question + '&question_user=' + val.questionUser + 
						'&question_time=' + val.questionTime
					});
				}else {
					uni.navigateTo({
						url: '/pages/question_answer/question_noanswer?id=' + val.id + '&question=' + val.question + '&question_user=' + val.questionUser + 
						'&question_time=' + val.questionTime
					});
				}
			}
		}
	}
</script>

<style>
</style>